import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name:  'Home',
    redirect: '/home/movie',
    component: () => import('../views/Home.vue'),
    children: [
      {
        path: '/home/movie',
        name: 'Movie',
        component: () => import('../pages/Movie.vue'),
      },
      {
        path: '/home/cinema',
        name: 'Cinema',
        component: () => import('../pages/Cinema.vue'),
      },
      {
        path: '/home/user',
        name: 'User',
        component: () => import('../pages/User.vue'),
      }
    ]
  },
  {
    path: '/movie_detail/:mid?/required',
    name: 'movieDetail',
    component: () => import('../views/movieDetail.vue')
  },
  {
    path: '*',
    component: () => import('../views/nullPage.vue')
  },
  {
    path: '/search-movie',
    name: 'searchMv',
    component: () => import('../views/searchMv.vue')
  },
  {
    path: '/cinema_detail/:cid?/required/:mid?',
    name: 'cinemaDetail',
    component: () => import('../views/cinemaDetail.vue')
  },
  {
    path: '/movie_buy/:cid?/:mid?/required',
    name: 'movieBuy',
    component: () => import('../views/movieBuy.vue')
  },
]

const router = new VueRouter({
  routes
})

const originalPush = VueRouter.prototype.push
   VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

export default router

